Hook WndProc

Otázka od: jsdelphi@creatix.cz

23. 9. 2004 23:19

Prosim o radu.

Potrebuju odchytit v komponente zmenu caption formulare. Zpravu WM_SETTEXT
se mi ale nedari odchytit. Co delam spatne?

constructor TXX.Create(AOwner: TComponent);
begin
  ...
  InstanceModalWndProc := MakeObjectInstance(ModalWndProc);
  OldModalWndProc := Pointer(GetWindowLong(Form.Handle, GWL_WNDPROC));
  SetWindowLong(Form.Handle, GWL_WNDPROC, Longint(InstanceModalWndProc));
end;

procedure TXX.ModalWndProc(var Message: TMessage);
begin
  case Message.Msg of
    WM_SYSCOMMAND: ... ok
    WM_DESTROY: ... ok
    WM_ACTIVATE: ... ok
    WM_SETTEXT: ... CHYBA, NIKDY NENASTANE
    CM_TEXTCHANGED: ... CHYBA, NIKDY NENASTANE
  end;

  Message.Result:= CallWindowProc(OldModalWndProc, Form.Handle, Message.Msg,
Message.WParam, Message.LParam);
end;

Diky za radu.

Jan Skopovy